package edu.nf.takeoutdemo.commons.base;


import edu.nf.takeoutdemo.commons.result.Result;
import org.springframework.http.HttpStatus;

/**
 *
 * @author zjl
 * @date 2025/10/19
 */
public class BaseController {
    public <T> Result<T> success(T data) {
        Result<T> vo = new Result<>();
        vo.setCode(HttpStatus.OK.value());
        vo.setData(data);
        return vo;
    }

    /**
     * 仅响应成功
     */
    public <T> Result<T> success() {
        Result<T> vo = new Result<>();
        vo.setCode(HttpStatus.OK.value());
        return vo;
    }

    public <T> Result<T> error(int code,String message){
        Result<T> vo = new Result<T>();
        vo.setCode(code);
        vo.setMessage(message);
        return vo;
    }

    public <T> Result<T> error(String message){
        Result<T> vo = new Result<>();
        vo.setMessage(message);
        return vo;
    }
}
